Skip to content

Conversation

@BatyLeo
Copy link
Member

@BatyLeo BatyLeo commented Jul 3, 2025

The goal of this PR is to increase the expressivity of the benchmarks interface, to allow for easy implmentations of stochastic and dynamic benchmark problems.

New abstract types

For this, we define two new sub abstract types of AbstractBenchmark:

AbstractDynamicBenchmark{exogenous} <: AbstractStochasticBenchmark{exogenous} <: AbstractBenchmark

Remarks:

  • This assumes any dynamic problem is also stochastic.
  • The two new types are parameterized by the exogenous parameter, a boolean indicating if the benchmark is exogenous or not (i.e. if one can generate scenarios and anticipative decisions).

New interface methods

For AbstractBenchmark

Implementing the full generate_dataset method can in practice be a bit tedious and verbose for no reason. While keeping the option to implement it for some applications where it makes sense, we propose an alternative where the user only needs to implement a generate_sample method that outputs a single DataSample instead of a full dataset:

generate_sample(::AbstractBenchmark, rng::AbstractRNG; kwargs...) -> DataSample

For AbstractStochasticBenchmark{true}

We need two new methods, one for generating scenarios, and one for computing anticipative decisions:

generate_scenario(::AbstractStochasticBenchmark{true}, instance, instance; kwargs...)
generate_anticipative_solution(::AbstractStochasticBenchmark{true}, instance, scenario; kwargs...)

For AbstractDynamicBenchmark

For dynamic problems, we additionally need to instantiate environments from instances. For this, we define the generate_environment and generate_environments methods. Similarly to generate_sample and generate_datasets, one may only need to implement the first one, that takes as inpout an instance and outputs an environment.

AbstractEnvironment

This environment type can be defined as a subtype of AbstractEnvironment, along with its associated methods:

  • get_seed
  • is_terminated
  • step!
  • observe
  • reset!

Additionally, we may want to apply RL algorithms to non-dynamic benchmarks, by considering them as dynamic problems with time horizon of length 1. We therefore propose a StaticEnv <: AbstractEnv wrapper around static instances for this (#35)

Policy

We also have a new generate_policies method

generate_policies(::AbstractBenchmark)

which outputs a tuple of Policy, i.e. policies to benchmark against.
In particular you can use run_policy! to run the policy on a given set of environments for a set number of episodes each.

New Benchmark problems

  • Dynamic Vehicle scheduling problem: simple example of an exogenous dynamic benchmark
  • Dynamic Assortment problem: simple example of an endogenous benchmark
    We plan to additionally implement the Dynamic VRP as well as the dynamic Inventory routing.

Points I'm unsure about

  • for implementing mirror descent algorithms on single stage stochastic benchmarks we will need additional maximizers, not sure where they belong in this interface
  • seed management
  • do we need to separate instance from environment?

TODO:

  • more tests
  • document new stuff

@codecov
Copy link

codecov bot commented Jul 3, 2025

Codecov Report

❌ Patch coverage is 89.68553% with 82 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/DynamicVehicleScheduling/maximizer.jl 81.33% 14 Missing ⚠️
src/DynamicVehicleScheduling/state.jl 87.50% 11 Missing ⚠️
src/DynamicVehicleScheduling/static_vsp/parsing.jl 90.66% 7 Missing ⚠️
src/DynamicVehicleScheduling/static_vsp/plot.jl 0.00% 7 Missing ⚠️
src/DynamicVehicleScheduling/policy.jl 71.42% 6 Missing ⚠️
src/DynamicVehicleScheduling/environment.jl 84.84% 5 Missing ⚠️
...rc/DynamicVehicleScheduling/static_vsp/instance.jl 54.54% 5 Missing ⚠️
src/DynamicVehicleScheduling/features.jl 88.57% 4 Missing ⚠️
src/Utils/policy.jl 88.88% 4 Missing ⚠️
...rc/DynamicVehicleScheduling/anticipative_solver.jl 97.22% 3 Missing ⚠️
... and 9 more
Files with missing lines Coverage Δ
src/Argmax/Argmax.jl 100.00% <100.00%> (ø)
src/Argmax2D/Argmax2D.jl 100.00% <100.00%> (ø)
src/DecisionFocusedLearningBenchmarks.jl 100.00% <100.00%> (ø)
src/DynamicAssortment/DynamicAssortment.jl 100.00% <100.00%> (ø)
src/DynamicAssortment/policies.jl 100.00% <100.00%> (ø)
...namicVehicleScheduling/DynamicVehicleScheduling.jl 100.00% <100.00%> (ø)
src/FixedSizeShortestPath/FixedSizeShortestPath.jl 93.87% <100.00%> (-0.13%) ⬇️
src/PortfolioOptimization/PortfolioOptimization.jl 91.66% <100.00%> (-0.23%) ⬇️
src/Ranking/Ranking.jl 100.00% <100.00%> (ø)
...cheduling/solution/algorithms/column_generation.jl 86.90% <100.00%> (ø)
... and 28 more

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@BatyLeo BatyLeo changed the title Interface overhaul for stochastic and dynamic benchmarks Interface overhaul Jul 8, 2025
@BatyLeo BatyLeo marked this pull request as ready for review August 8, 2025 15:45
@BatyLeo BatyLeo merged commit 1e57bde into main Aug 22, 2025
3 checks passed
@BatyLeo BatyLeo deleted the dynamic-interface-poc branch August 22, 2025 07:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants